package com.iccaplayer.sequencer;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.util.Log;

public class Matrix {
	private static final String TAG = "Matrix";
	
	public static final int TOTAL_SAMPLES = 5;
	public static final int TOTAL_BEATS = 3600;
	
	private int samples;		// number of samples
	private int beats;	// number of beats
//	private int[] samples; //
	private Cell[][] data = new Cell[TOTAL_SAMPLES][TOTAL_BEATS];
//	private List<Cell> data;
	private Context context;
	private boolean enabled;
	
	public Matrix(Context ctx, int rows, int cols){
		context = ctx;
		samples = rows;
		beats = cols;
		enabled = false;
		
		for(int i=0; i<samples; i++){
			for(int j=0; j<beats; j++){
				data[i][j] = new Cell();
//				Log.d(TAG, i + "," + j + "is create.");
			}
		}
	}	
	
	public void setCellValue(int row, int col, boolean value){
		data[row][col].setValue(value);
	}
	
	public boolean getCellValue(int row, int col){
		return (data[row][col]).getValue();
	}
	
	public void setCellKey(int row, int col, String key){
		data[row][col].setKey(key);
	}
	
	public String getCellKey(int row, int col){
		return (data[row][col]).getKey();
	}
	
	public void growCells(int n){		
		int newBeats;
		newBeats = beats + n;
		
		for(int i=0; i<samples; i++){
			for(int j=beats; j<newBeats; j++)
				data[i][j] = new Cell();
		}
		
		beats = newBeats;
	}
	
	public void shrinkCells(int n){
		int newBeats;
		newBeats = beats - n;
		
		for(int i=0; i<samples; i++){
			for(int j=beats-1; j>newBeats; j--)
				data[i][j].setValue(false);
		}
		
		beats = newBeats;
	}
	
}
